//
//  ModelRepaymentCodeList.m
//  MexicoLoan
//
//  Created by wxp on 2025/3/19.
//

#import "ModelRepaymentCodeList.h"

NSString *const kRepaymentCodeListRepaymentLead = KEY_repaymentLead;
NSString *const kRepaymentCodeListHint = KEY_hint;
NSString *const kRepaymentCodeListRepaymentBank = KEY_repaymentBank;
NSString *const kRepaymentCodeListPaymentCode = KEY_paymentCode;
NSString *const kRepaymentCodeListExpireTime = KEY_expireTime;
NSString *const kRepaymentCodeListBarcodeUrlAlfa = KEY_barcodeUrlAlfa;


@interface ModelRepaymentCodeList ()

- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict;

@end

@implementation ModelRepaymentCodeList

@synthesize repaymentLead = _repaymentLead;
@synthesize hint = _hint;
@synthesize repaymentBank = _repaymentBank;
@synthesize paymentCode = _paymentCode;
@synthesize expireTime = _expireTime;
@synthesize barcodeUrlAlfa = _barcodeUrlAlfa;


+ (instancetype)modelObjectWithDictionary:(NSDictionary *)dict {
    return [[self alloc] initWithDictionary:dict];
}

- (instancetype)initWithDictionary:(NSDictionary *)dict {
    self = [super init];
    if (self && [dict isKindOfClass:[NSDictionary class]]) {
        self.repaymentLead = [self objectOrNilForKey:kRepaymentCodeListRepaymentLead fromDictionary:dict];
        self.hint = [self objectOrNilForKey:kRepaymentCodeListHint fromDictionary:dict];
        self.repaymentBank = [self objectOrNilForKey:kRepaymentCodeListRepaymentBank fromDictionary:dict];
        self.paymentCode = [self objectOrNilForKey:kRepaymentCodeListPaymentCode fromDictionary:dict];
        self.expireTime = [[self objectOrNilForKey:kRepaymentCodeListExpireTime fromDictionary:dict] doubleValue];
        self.barcodeUrlAlfa = [self objectOrNilForKey:kRepaymentCodeListBarcodeUrlAlfa fromDictionary:dict];
    }
    return self;
}

- (NSDictionary *)dictionaryRepresentation {
    NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
    [mutableDict setValue:self.repaymentLead forKey:kRepaymentCodeListRepaymentLead];
    [mutableDict setValue:self.hint forKey:kRepaymentCodeListHint];
    [mutableDict setValue:self.repaymentBank forKey:kRepaymentCodeListRepaymentBank];
    [mutableDict setValue:self.paymentCode forKey:kRepaymentCodeListPaymentCode];
    [mutableDict setValue:self.barcodeUrlAlfa forKey:kRepaymentCodeListBarcodeUrlAlfa];
    [mutableDict setValue:[NSNumber numberWithDouble:self.expireTime] forKey:kRepaymentCodeListExpireTime];
    return [NSDictionary dictionaryWithDictionary:mutableDict];
}

- (NSString *)description  {
    return [NSString stringWithFormat:@"%@", [self dictionaryRepresentation]];
}

- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict {
    id object = [dict objectForKey:aKey];
    return [object isEqual:[NSNull null]] ? nil : object;
}

@end
